/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cn.ekuma.epos.datalogic.define.dao.erp;

import cn.ekuma.data.dao.BaseDAO;
import cn.ekuma.epos.db.table.erp.I_TimeStoreLine;

import com.openbravo.data.basic.BasicException;
import com.openbravo.data.loader.DataRead;
import com.openbravo.data.loader.DataWrite;
import com.openbravo.data.loader.I_Session;
import com.openbravo.data.loader.TableDefinition;
import com.openbravo.bean.erp.TimeStoreLine;
import com.openbravo.data.loader.Datas;
import com.openbravo.data.loader.SerializerWriteString;
import com.openbravo.data.loader.StaticSentence;
import com.openbravo.data.model.Field;
import com.openbravo.format.Formats;

/**
 *
 * @author Administrator
 */
public class TimeStoreLineDAO extends BaseDAO<TimeStoreLine> {

    public TimeStoreLineDAO(I_Session s) {
        super(s);
    }

    @Override
    public TableDefinition getTable() {
        return new TableDefinition(s,
                  "TIMESTORELINES",
                  new Field[]{
        		       new Field(I_TimeStoreLine.ID,Datas.STRING,Formats.STRING),
                       new Field(I_TimeStoreLine.TIMESTOREID,Datas.STRING,Formats.STRING),
                       new Field(I_TimeStoreLine.PRODUCT,Datas.STRING,Formats.STRING),
                       new Field(I_TimeStoreLine.ATTRIBUTESETINSTANCE_ID,Datas.STRING,Formats.STRING),
                       new Field(I_TimeStoreLine.UNITS,Datas.DOUBLE,Formats.DOUBLE)
                      },
                  new int[]{0});
    }

    @Override
    public void writeInsertValues(DataWrite dp, TimeStoreLine obj) throws BasicException {
    	  dp.setString(1,obj.getKey());
          dp.setString(2,obj.getRefID());
          dp.setString(3,obj.getProductID());
          dp.setString(4,obj.getAttributesetid());
          dp.setDouble(5,obj.getMultiply());
    }

    public TimeStoreLine readValues(DataRead dr,TimeStoreLine obj) throws BasicException {
          if(obj==null)
        	  obj=new TimeStoreLine();  
          obj.setKey(dr.getString(1));
          obj.setRefID(dr.getString(2));
          obj.setProductID(dr.getString(3));
          obj.setAttributesetid(dr.getString(4));
          obj.setMultiply(dr.getDouble(5));
          return obj;
    }

    @Override
    public Class getSuportClass() {
       return TimeStoreLine.class;
    }

    public void deleteTimeStoreLines(String timeStoreId) throws BasicException {
        new StaticSentence(s, "DELETE FROM TIMESTORELINES WHERE TIMESTOREID = ?", SerializerWriteString.INSTANCE).exec(timeStoreId);
    }



}
